<?php
class TotalModel extends Model {
	
	/**
	 * 会员数据统计
	 * ordtotal|prototal|allprice|yhprice
	 * yhjtotal|viptotal|acttotal
	 */
	public function memberTotal(){
		
		$userid = session(C("USER_AUTH_IDEN"));
		
		$tmap['user_id'] = $userid ;
		$total = $this->where($tmap)->find();
		//没有记录则创建
		if(empty($total['id'])){
			$tmap['addtime'] = time();
			$id  = $this->add($tmap);
			$total = $this->find($id);
		}
		
		$smap['fromid'] = $userid ;
		$share = M("Sharelog")->where($smap)->count("id");
		
		$gmap['userid'] = $userid ;
		$guest = M("Share")->where($gmap)->count("id");
		
		$total['share'] = $share;
		$total['guest'] = $guest;
		
		return $total;
	}
	
	
	
	
}
		
?>